package com.yangcheng.dao;


import com.yangcheng.model.domain.Comment;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * (TComment)表数据库访问层
 *
 * @author makejava
 * @since 2021-04-12 17:10:30
 */
@Mapper
public interface CommentMapper {
    //展示某个文章的评论
    @Select("SELECT * from t_comment where article_id=#{aid} ORDER BY id DESC")
    public List<Comment> selectCommentWithPage(Integer aid);
    //后台查询最新评论
    @Select("SELECT * from t_comment ORDER BY id DESC ")
    public List<Comment> selectNewComment();
    //发表评论
    @Insert("INSERT INTO t_comment (article_id, created, author, ip, content)" +
            " VALUES (#{articleId},#{created},#{author},#{ip},#{content})")
    public void pushComment(Comment comment);
    //站点统计，统计评论数量
    @Select("SELECT count(1) FROM t_comment")
    public Integer countComment();
    //通过文章id删除评论信息
    @Delete("DELETE FROM t_comment WHERE article_id=#{aid}")
    public void deleteCommentWithId(Integer aid);
}